/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ConsultaCandidat.java
 *
 * Created on 27/03/2011, 02:06:30 AM
 */

package zonasoft.Vistas.Funcionales;

import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import zonasoft.Conceptos.Candidato;
import zonasoft.Conceptos.Eleccion;
import zonasoft.Manejadores.ManejadorBaseDatos;
import zonasoft.Manejadores.ManejadorCandidato;
import zonasoft.Manejadores.ManejadorEleccion;
import zonasoft.Vistas.Negocio.RegistrarZonificado;
import zonasoft.Vistas.VentanaPrincipal;

/**
 *
 * @author Usuario
 */
public class ConsultaCandidato extends javax.swing.JFrame {

    /** Creates new form ConsultaCandidat */
    public ConsultaCandidato() {
        initComponents();
        this.setLocationRelativeTo(null);
    }
HashMap<String,Integer> elecciones;
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jXTaskPaneContainer1 = new org.jdesktop.swingx.JXTaskPaneContainer();
        jLabel1 = new javax.swing.JLabel();
        jXPanel1 = new org.jdesktop.swingx.JXPanel();
        campoNombre = new javax.swing.JTextField();
        campoprofesion = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        campoapellido = new javax.swing.JTextField();
        campotelefono = new javax.swing.JTextField();
        campoIdentificacion = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        campoBarrio = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        areaDireccion = new javax.swing.JTextArea();
        jLabel16 = new javax.swing.JLabel();
        checkboxS = new javax.swing.JCheckBox();
        checkboxN = new javax.swing.JCheckBox();
        jXPanel2 = new org.jdesktop.swingx.JXPanel();
        BotonAceptar = new javax.swing.JButton();
        BotonConsultar = new javax.swing.JButton();
        BotonLimpiar = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        comboeleccion = new javax.swing.JComboBox();
        botonLideres = new javax.swing.JButton();
        botonZonificado = new javax.swing.JButton();

        jLabel1.setFont(new java.awt.Font("Lucida Bright", 3, 18)); // NOI18N
        jLabel1.setText("Consulta de Candidatos");
        jXTaskPaneContainer1.add(jLabel1);

        jXPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, java.awt.Color.gray, java.awt.Color.lightGray, java.awt.Color.gray, java.awt.Color.lightGray), "Datos Candidatos", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Lucida Bright", 1, 12))); // NOI18N

        campoNombre.setEditable(false);

        campoprofesion.setEditable(false);

        jLabel9.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel9.setText("Nombre");

        jLabel10.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel10.setText("Correo");

        jLabel12.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel12.setText("Telefono");

        jLabel11.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel11.setText("Apellidos");

        campoapellido.setEditable(false);

        campotelefono.setEditable(false);

        campoIdentificacion.setEditable(false);

        jLabel13.setFont(new java.awt.Font("Lucida Bright", 0, 12)); // NOI18N
        jLabel13.setText("Identificacion");

        jLabel14.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel14.setText("Barrio");

        campoBarrio.setEditable(false);

        jLabel15.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel15.setText("Direccion");

        areaDireccion.setColumns(20);
        areaDireccion.setEditable(false);
        areaDireccion.setRows(5);
        jScrollPane1.setViewportView(areaDireccion);

        jLabel16.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel16.setText("Hoja de Vida");

        checkboxS.setText("Si");
        checkboxS.setEnabled(false);
        checkboxS.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkboxSActionPerformed(evt);
            }
        });

        checkboxN.setText("No");
        checkboxN.setEnabled(false);
        checkboxN.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkboxNActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jXPanel1Layout = new javax.swing.GroupLayout(jXPanel1);
        jXPanel1.setLayout(jXPanel1Layout);
        jXPanel1Layout.setHorizontalGroup(
            jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel13)
                    .addComponent(jLabel9)
                    .addComponent(jLabel10)
                    .addComponent(jLabel14))
                .addGap(18, 18, 18)
                .addGroup(jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(campoprofesion, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE)
                    .addComponent(campoBarrio, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE)
                    .addComponent(campoNombre, javax.swing.GroupLayout.DEFAULT_SIZE, 168, Short.MAX_VALUE)
                    .addComponent(campoIdentificacion, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(28, 28, 28)
                .addGroup(jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jXPanel1Layout.createSequentialGroup()
                        .addGroup(jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel11)
                            .addComponent(jLabel12))
                        .addGap(18, 18, 18)
                        .addGroup(jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(campotelefono)
                            .addComponent(campoapellido, javax.swing.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE)))
                    .addGroup(jXPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel15)
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jXPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel16)
                        .addGap(44, 44, 44)
                        .addComponent(checkboxS)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(checkboxN)))
                .addContainerGap())
        );
        jXPanel1Layout.setVerticalGroup(
            jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jXPanel1Layout.createSequentialGroup()
                        .addGroup(jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel13)
                            .addComponent(campoIdentificacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel16)
                            .addComponent(checkboxS)
                            .addComponent(checkboxN))
                        .addGap(18, 18, 18)
                        .addGroup(jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel9)
                            .addComponent(campoNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(26, 26, 26)
                        .addGroup(jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel10)
                            .addComponent(campoprofesion, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jXPanel1Layout.createSequentialGroup()
                        .addGroup(jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(campoapellido, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel11))
                        .addGap(26, 26, 26)
                        .addGroup(jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(campotelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel12))))
                .addGap(18, 18, 18)
                .addGroup(jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jXPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel14)
                        .addComponent(campoBarrio, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel15))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(31, Short.MAX_VALUE))
        );

        jXPanel2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, java.awt.Color.lightGray, java.awt.Color.gray, java.awt.Color.lightGray, java.awt.Color.gray));

        BotonAceptar.setFont(new java.awt.Font("Lucida Bright", 1, 12));
        BotonAceptar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/zonasoft/Vistas/iconos/ok 32.png"))); // NOI18N
        BotonAceptar.setText("Aceptar");
        BotonAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotonAceptarActionPerformed(evt);
            }
        });

        BotonConsultar.setFont(new java.awt.Font("Lucida Bright", 1, 12)); // NOI18N
        BotonConsultar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/zonasoft/Vistas/iconos/search-icon2.png"))); // NOI18N
        BotonConsultar.setText("Consultar");
        BotonConsultar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotonConsultarActionPerformed(evt);
            }
        });

        BotonLimpiar.setFont(new java.awt.Font("Lucida Bright", 1, 12));
        BotonLimpiar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/zonasoft/Vistas/iconos/limpiar.png"))); // NOI18N
        BotonLimpiar.setText("Limpiar");
        BotonLimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotonLimpiarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jXPanel2Layout = new javax.swing.GroupLayout(jXPanel2);
        jXPanel2.setLayout(jXPanel2Layout);
        jXPanel2Layout.setHorizontalGroup(
            jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jXPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(BotonConsultar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 137, Short.MAX_VALUE)
                    .addComponent(BotonAceptar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 137, Short.MAX_VALUE)
                    .addComponent(BotonLimpiar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 137, Short.MAX_VALUE))
                .addContainerGap())
        );
        jXPanel2Layout.setVerticalGroup(
            jXPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jXPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(BotonConsultar, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(BotonLimpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(BotonAceptar)
                .addContainerGap(16, Short.MAX_VALUE))
        );

        jLabel8.setFont(new java.awt.Font("Lucida Bright", 0, 12));
        jLabel8.setText("Id Eleccion");

        listararEleccion();
        comboeleccion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                comboeleccionActionPerformed(evt);
            }
        });

        botonLideres.setFont(new java.awt.Font("Lucida Bright", 1, 12));
        botonLideres.setIcon(new javax.swing.ImageIcon(getClass().getResource("/zonasoft/Vistas/iconos/user-3-iconB.png"))); // NOI18N
        botonLideres.setText("Lideres");
        botonLideres.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonLideresActionPerformed(evt);
            }
        });

        botonZonificado.setFont(new java.awt.Font("Lucida Bright", 1, 12));
        botonZonificado.setIcon(new javax.swing.ImageIcon(getClass().getResource("/zonasoft/Vistas/iconos/user-1-iconB.png"))); // NOI18N
        botonZonificado.setText("Zonificados");
        botonZonificado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonZonificadoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jXPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jXPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(27, 27, 27))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(comboeleccion, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(534, Short.MAX_VALUE))))
            .addComponent(jXTaskPaneContainer1, javax.swing.GroupLayout.DEFAULT_SIZE, 769, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(303, Short.MAX_VALUE)
                .addComponent(botonLideres)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(botonZonificado)
                .addGap(208, 208, 208))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jXTaskPaneContainer1, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(comboeleccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jXPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(botonZonificado)
                            .addComponent(botonLideres)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(97, 97, 97)
                        .addComponent(jXPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void comboeleccionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboeleccionActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_comboeleccionActionPerformed

    private void BotonAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonAceptarActionPerformed
        // TODO add your handling code here:
        this.dispose();
    }//GEN-LAST:event_BotonAceptarActionPerformed

    private void BotonConsultarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonConsultarActionPerformed
        // TODO add your handling code here:
    String idCandidato =campoIdentificacion.getText().trim();
        limpiar();
        ManejadorBaseDatos manejabd = ManejadorBaseDatos.getInstancia();
        try {
            manejabd.conectar();
            ManejadorCandidato.con=manejabd.getConexion();
            Candidato can = null;
String nombreEleccion=comboeleccion.getSelectedItem().toString();
//            System.out.println("nombreEleccion = " + nombreEleccion);
Integer idEleccionSelecionada=elecciones.get(nombreEleccion);
//            System.out.println("idEleccionSelecionada = " + idEleccionSelecionada);

//String.valueOf(Integer idEleccionSelecionada=elecciones.get(nombreEleccion));
String id = (String.valueOf( idEleccionSelecionada));

can = ManejadorCandidato.getCandidatoE(id,idCandidato);
System.out.println("trae C "+can==null);
if (can != null){
            campoIdentificacion.setText(can.getIdCandidato());
            campoNombre.setText(can.getNombre());
            campoapellido.setText(can.getApellido());
            campoprofesion.setText(can.getCorreo());
            campotelefono.setText(can.getTelefono());
            campoBarrio.setText(can.getBarrio());
            areaDireccion.setText(can.getDireccion());
            int  hoja = can.getHojaVida();
                  if(hoja ==1){
                      checkboxN.setSelected(false);
                  checkboxS.setSelected(true);
                           }else{
                           checkboxS.setSelected(false);
                           checkboxN.setSelected(true);
                           }
}else{
JOptionPane.showMessageDialog(null," Esta Eleccion no Tiene Candidato Asociado", "Busqueda sin resultados",JOptionPane.INFORMATION_MESSAGE);
}
        } catch (Exception ex) {
            // Logger.getLogger(ConsultaEleccion.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(null," Esta Eleccion no Tiene Candidato Asociado", "Busqueda sin resultados",JOptionPane.INFORMATION_MESSAGE);
//        ex.printStackTrace();
        }    
    }//GEN-LAST:event_BotonConsultarActionPerformed

    private void BotonLimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonLimpiarActionPerformed
        // TODO add your handling code here:
        limpiar();
    }//GEN-LAST:event_BotonLimpiarActionPerformed

    private void checkboxSActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkboxSActionPerformed
        // TODO add your handling code here:
        checkboxN.setSelected(false);
    }//GEN-LAST:event_checkboxSActionPerformed

    private void checkboxNActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkboxNActionPerformed
        // TODO add your handling code here:
        checkboxS.setSelected(false);
}//GEN-LAST:event_checkboxNActionPerformed


    private void botonLideresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonLideresActionPerformed
        // TODO add your handling code here:
          if(!campoNombre.getText().isEmpty()){
        VentanaPrincipal vp = null;
        try {
            vp = new VentanaPrincipal();
        } catch (IOException ex) {
            Logger.getLogger(ConsultaCandidato.class.getName()).log(Level.SEVERE, null, ex);
        }
      new RegistrarLider(vp).setVisible(true);
        }else{
        JOptionPane.showMessageDialog(null,"realice la consulta por favor","campos vacios",JOptionPane.WARNING_MESSAGE);
        }
}//GEN-LAST:event_botonLideresActionPerformed

    private void botonZonificadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonZonificadoActionPerformed
        // TODO add your handling code here:
        // TODO add your handling code here:
          if(!campoNombre.getText().isEmpty()){
        VentanaPrincipal vp = null;
        try {
            vp = new VentanaPrincipal();
        } catch (IOException ex) {
            Logger.getLogger(ConsultaCandidato.class.getName()).log(Level.SEVERE, null, ex);
        }
       new RegistrarZonificado(vp).setVisible(true);
        }else{
        JOptionPane.showMessageDialog(null,"realice la consulta por favor","campos vacios",JOptionPane.WARNING_MESSAGE);
        }

}//GEN-LAST:event_botonZonificadoActionPerformed

    public void limpiar(){
      campoIdentificacion.setText("");
             campoNombre.setText("");
            campoapellido.setText("");
            campoprofesion.setText("");
            campotelefono.setText("");  
            checkboxS.setSelected(false);
            checkboxN.setSelected(false);
            areaDireccion.setText("");
    }

      
     public void listararEleccion()  {
    ManejadorBaseDatos mbd=ManejadorBaseDatos.getInstancia();
     elecciones=new HashMap<String,Integer>();
         try{
               mbd.conectar();
               ManejadorEleccion.con = mbd.getConexion();
               comboeleccion.removeAllItems();
               //ManejadorEleccion.listarElecciones();

            List listarElecciones = null;
      //   listarpaises = ManejadorPais.getlistaPais();
         listarElecciones = ManejadorEleccion.listarElecciones();
            Iterator<Eleccion> iter = listarElecciones.iterator();
            Eleccion e = null;
            while (iter.hasNext()) {
                e = iter.next();
                int idEleccion=Integer.parseInt(e.getIdEleccion());
                comboeleccion.addItem(e.getNombre());
                elecciones.put(e.getNombre(),idEleccion);
            }
         }catch (Exception ex){
            ex.printStackTrace();
           }
         }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BotonAceptar;
    private javax.swing.JButton BotonConsultar;
    private javax.swing.JButton BotonLimpiar;
    private javax.swing.JTextArea areaDireccion;
    private javax.swing.JButton botonLideres;
    private javax.swing.JButton botonZonificado;
    private javax.swing.JTextField campoBarrio;
    private javax.swing.JTextField campoIdentificacion;
    private javax.swing.JTextField campoNombre;
    private javax.swing.JTextField campoapellido;
    private javax.swing.JTextField campoprofesion;
    private javax.swing.JTextField campotelefono;
    private javax.swing.JCheckBox checkboxN;
    private javax.swing.JCheckBox checkboxS;
    private javax.swing.JComboBox comboeleccion;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private org.jdesktop.swingx.JXPanel jXPanel1;
    private org.jdesktop.swingx.JXPanel jXPanel2;
    private org.jdesktop.swingx.JXTaskPaneContainer jXTaskPaneContainer1;
    // End of variables declaration//GEN-END:variables

}
